package com.tedu.bill;

import java.util.Scanner;

/**
 * Author：毕龙
 * Date: 2024/3/24 15:56
 */
public class TestProductShopStore {
    public static void main(String[] args) {
        /**
         * 1.商品的编号
         * 2.付款金额
         */
        System.out.println("1.娃哈哈纯净水  2.乐虎  3.冰糖雪梨");
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入编号：");
        int no = sc.nextInt();
        //将返回的金额接收
        double money = selectNo(no);
        System.out.println(money+"元");
        boolean isOk = pay(money);
        if(isOk){
            System.out.println("付款成功");
        }else{
            System.out.println("付款失败");
            return;
        }
        String result = buyOk(no, isOk);
        System.out.println(result);
    }

    public static String buyOk(int no,boolean isOk){
        if(no == 1 && isOk){
            return "娃哈哈纯净水";
        }else if(no == 2 && isOk){
            return "乐虎";
        }else if(no == 3 && isOk){
            return "冰糖雪梨";
        }else{
            return "null";
        }
    }
    //付款
    public static boolean pay(double money){
        Scanner sc = new Scanner(System.in);
        System.out.println("请付款：");
        double pay= sc.nextDouble();
        if(pay == money){
            return true;
        }
        return false;
    }
    //选择编号功能
    public static double selectNo(int no){
        if(no == 1){
            return 2;
        }else if(no == 2){
            return 5;
        }else if(no == 3){
            return 4;
        }else{
            return 0;
        }
    }

}
